A port channel of a network switch may be a logical interface that includes a certain number physical ports logically bundled together. For example, a port channel may have 2N physical ports where N is a positive integer. A port channel's bandwidth may be the total bandwidth of all physical ports within the port channel. To fully leverage each physical port within a port channel, traffic load needs to be balanced among all physical ports. In prior implementations, each physical port may be assigned a set of values (aka “hash”) ranging from 0 to 2N−1. The values may be pre-assigned to each port when adding or deleting a port within a port channel. When traffic flows arrive at a port channel, a hash algorithm may be applied to compute hash values based on hash inputs derived from a traffic flow's parameters such as source IP, destination IP, source MAC, destination MAC, etc. The flow may be directed to the corresponding physical port whose pre-assigned values are matched with the hash function output.
However, such prior systems have a number of problems when attempting to achieve even traffic load-balancing among ports in a port channel with 2N ports. First, as the number of ports in a port channel can range from 1 to 2N, if the number of ports is not a binary number, the hash values ranging from 0 to 2N−1 may not be evenly distributed among ports which can cause uneven traffic load-balancing among ports. Second, when N scales, it may be difficult to know how to assign the hash values evenly given different number of ports in a port channel without scalability factors.